// 作用域，提升
var a = 100
var b = 200;
function test(a , b){
	console.log(a); //f a() {}
	console.log(b); //undefined
	var b = 234;
	console.log(b);	//234
	a = 123;
	console.log(a);	//123
	function a (){}
	var a;
	b = 234;
	var b = function(){}
	console.log(a);	//123
	console.log(b);	//f() {}
}
test(1);


// 闭包
function a() {
	function b() {
		var bb = 234;
		console.log(aaa);
	}
	var aaa = 123;
	return b;
}

var glob = 100;
var demo = a();

demo()

//打印出 100 以内的质数（从 1 除到他本身，只能有两个因数）

var count = 0; // 用于计数
for (var i = 2; i < 100; i++) {
	// for (var j = 1; j <= i: j++)
	for (var j = 1; j <= Math.sqrt(i); j++) {
		if (i % j == 0) {
			count++;
		}
	}
	if (count == 1) {
		console.log('质素：', i)
	}
	//计数归0
	count = 0;
}

//对象键值对转换

let o = {a: 12, b: 23};

function trans(obj) {
	let b = {};
	for(var key in obj) {
		b[obj[key]] = key;
	}
	return b;
}

let b = trans(o)